package com.example.badmintonDB.Server;
import com.example.badmintonCommon.entity.Order;
import com.example.badmintonCommon.entity.User;
import com.example.badmintonDB.dao.GymMapper;
import com.example.badmintonDB.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.badmintonDB.UserDBServer;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserDBServerImpl implements UserDBServer {

    private final UserMapper userMapper;
    private final GymMapper gymMapper;
    @Autowired
    public UserDBServerImpl(UserMapper userMapper,GymMapper gymMapper){
        this.userMapper=userMapper;
        this.gymMapper=gymMapper;
    }

    //通过手机号查看用户是否存在
    @Override
    public Boolean existsByUserTel(String tel){
       return userMapper.existsByUserTel(tel);
    }

    //通过手机号注册用户
    @Override
    public void RegisterByUserTel(User user){
        userMapper.RegisterByUserTel(user);
    }

    //通过手机号查看用户手机号是否正确
    @Override
    public Boolean RightByPsw(String tel, String psw){
        return userMapper.RightByPsw(tel,psw);
    }

    //通过手机号查看用户所有订单
    @Override
    public  List<Order> ShowAllOderByTel(String tel) {
        return userMapper.ShowAllOderByTel(tel);
    };

    //通过手机号获得用户密码
    @Override
    public String getPasswordByTel(String tel) {
        return userMapper.getPasswordByTel(tel);
    }

    //通过手机号获得用户身份
    @Override
    public String getRoleByTel(String tel) {
        return userMapper.getRoleByTel(tel);
    }

    //通过手机号获得用户是否黑户
    @Override
    public int getIslockByTel(String tel) {
        return userMapper.getIslockByTel(tel);
    }

    @Override
    public User getUserInfo(String tel) {
        return userMapper.getUserInfo(tel);
    }

    //用户修改信息
    @Override
    public void editmessage(String tel,String name, String sex){
        userMapper.editmessage(tel,name,sex);
    }

    //用户修改信息
    @Override
    public void editpsw(String tel,String psw){
         userMapper.editpsw(tel,psw);
    }
}
